﻿namespace Gasgoo.ShareLibrary.Framework.Options
{
    public class AdoNetOptions
    {
        private string _connection { get; }

        public string DataSource { get; set; }

        public string UID { get; set; }

        public string PWD { get; set; }

        public string DatabaseName { get; set; } = "Gasgoo.ClusterComponent";


        public string QueueDatabaseName { get; set; } = "Gasgoo.QueueStorage";


        public AdoNetOptions()
        {
        }

        public AdoNetOptions(string connection)
        {
            _connection = connection;
        }

        public string GetConnection(string tableName = null)
        {
            if (string.IsNullOrWhiteSpace(PWD))
            {
                return "Data Source=" + DataSource + ";database=" + (tableName ?? DatabaseName) + ";Integrated Security=True;MultipleActiveResultSets=true;";
            }

            return "Data Source=" + DataSource + ";database=" + (tableName ?? DatabaseName) + ";uid=" + UID + ";pwd=" + PWD + ";MultipleActiveResultSets=true;";
        }
    }
}